<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="lb" uri="/WEB-INF/tag/paginationTag.tld"%>
<head>
    <%@ include file="template/head.jsp" %>
</head>
<script type="text/javascript">
    $(function(){
        $(".pay").click(function(){
            var tr=$(this).parent().parent();
            var td=$(tr).children(":first-child").next();
            var id=$(td).text();
            $.ajax({
                url:"/listServlet/update",
                type:"POST",
                data:{"listid":id,"attitude":"DOING_OUT"},
                dataType:"text",
            }).done(function(txt){
                if(eval(txt)>0){
                   $(tr).children(":nth-child(4)").html("正在配货");
                }
            });
        });
        $(".undo").click(function(){
            var tr=$(this).parent().parent();
            var td=$(tr).children(":first-child").next();
            var id=$(td).text();
            $.ajax({
                url:"/listServlet/update",
                type:"post",
                data:{"listid":id,"attitude":"CANCEL_LIST"},
                dataType:"text",
            }).done(function(txt){
                if(eval(txt)>0){
                    $(tr).children(":nth-child(4)").html("已取消");
                }
            });
        });
    });
</script>
<body>
<!-- Left sidebar start -->
<aside id="sidebar">
    <%@ include file="template/aside.jsp" %>
</aside>
<!-- Left sidebar end -->

<!-- Dashboard Wrapper Start -->
<div class="dashboard-wrapper">

    <!-- Header start -->
    <header>

    </header>
    <!-- Header ends -->

    <!-- Right sidebar start -->
    <div class="sb-slidebar sb-right sb-close">

        <!-- User Profile Start -->
        <section class="user-profile">

        </section>
    </div>
    <!-- Right sidebar end -->

    <!-- Main Container Start -->
    <div class="main-container">

        <!-- Top Bar Starts -->
        <div class="top-bar clearfix">

        </div>
        <!-- Top Bar Ends -->

        <!-- Container fluid Starts -->
        <div class="container-fluid">
            <table class="table" style="color:black;">
                <thead>
                    <tr>
                        <th align="center">编号</th>
                        <th align="center">订单编号</th>
                        <th align="center">订单总金额(元)</th>
                        <th align="center">订单状态</th>
                        <th align="center">订单来源</th>
                        <th align="center">下单时间</th>
                        <th align="center">收货人姓名</th>
                        <th align="center">收货人电话</th>
                        <th align="center">收货人地址</th>
                    </tr>
                </thead>
                <tbody>
                    <c:if test="${empty sessionScope.LIST }">
                        <tr>
                            <td colspan="9" align="center">该用户还没有订单</td>
                        </tr>
                    </c:if>
                    <c:if test="${not empty sessionScope.LIST.listModels }">
                        <c:forEach items="${sessionScope.LIST.listModels }" var="lm" varStatus="suoyin">
                            <tr>
                                <td align="center">${suoyin.index+1}</td>
                                <td align="center">${lm.listid}</td>
                                <td align="center">
                                    <fmt:formatNumber value="${lm.sums}" pattern="0.00"/>
                                </td>
                                <c:if test="${lm.attutide eq 'NO_PAYMENT'}">
                                    <td align="center">
                                        <input class="pay" type="button" value="支付">&nbsp;
                                        <input class="undo" type="button" value="取消">
                                    </td>
                                </c:if>
                                <c:if test="${lm.attutide ne 'NO_PAYMENT'}">
                                    <td align="center">${lm.attutide.text}</td>
                                </c:if>
                                <td align="center">${lm.listfrom.text}</td>
                                <td align="center">
                                     <fmt:formatDate value="${lm.thistime}" pattern="yyyy-MM-dd HH-mm-ss"/>
                                </td>
                                <td align="center">${lm.toname}</td>
                                <td align="center">${lm.totele}</td>
                                <td align="center">${lm.toaddress}</td>
                            </tr>
                        </c:forEach>
                    </c:if>
                </tbody>
            </table>
            <lb:pagination paging="${LIST}"/>
        </div>
        <!-- Container fluid ends -->
    </div>
    <!-- Main Container Start -->

    <!-- Footer Start -->
        <%@include file="template/footer.jsp"%>
    <!-- Footer end -->
</div>
<!-- Dashboard Wrapper End -->

</body>
</html>